The main objective of this project is to develop novel statistical methods for investigating heterogeneity in daily cocaine use trajectories among cocaine dependents. The specific aims of this project are to: 1) derive informative summary measures for daily cocaine use trajectories and use such summary measures to subtype these trajectories; 2) link posttreatment cocaine craving/stress and cocaine relapse to baseline variables while accounting for measurement error in the derived baseline summary measures; 3) understand the dynamic relationship between posttreatment cocaine craving/stress and cocaine relapse; 4) implement the developed statistical methods in a user-friendly computer package and make it available to the scientific community. To achieve these aims, we will develop cutting-edge statistical methods covering several areas including functional data analysis, measurement error and joint modeling of longitudinal and recurrent event data. Statistical properties of these methods will be thoroughly investigated through both rigorous theoretical derivation as well as extensive simulation. Specifically, the proposed functional data analysis techniques can help generate novel and more accurate subtypes for one's cocaine use patterns. The proposed methods accounting for measurement error can significantly reduce the potentially large bias in estimated regression coefficients due to measurement error and hence lead to more objective assessment of risk factors and treatment effect. The proposed statistical methods for modeling recurrent event processes allow us to make full use of the rich information contained in one's en- tire cocaine relapse trajectory, and thus can be more powerful in identifying risk factors as well as in detecting treatment effect. The proposed joint modeling of longitudinal and recurrent event data allows us to assess the relationship between cocaine relapse and time varying variables such as craving and stress. A greater understanding of this relationship can inspire the development of novel pharmacological strategies to treat cocaine dependence. In terms of statistical innovation, we introduce the novel concept of conducting functional data analysis for the mean and correlation structures of a stochastic process simultaneously, develop nonparametric methods to account for the measurement error when some predictors are derived from a stochastic process, and propose computationally efficient algorithms to jointly model longitudinal and recurrent event data.